function qqq(date) {
    var arr = [];
    for (var i in date) {
        var str = i + '=' + date[i]
        arr.push(str)
    }
    return arr.join('&')
}
// var oo = qqq({ name: 'zs', age: 20 })
// console.log(oo);
function itheima(option) {
    var xhr = new XMLHttpRequest()
    // 把外界传递过来的参数对象 转化为字符串
    var qs = qqq(option.date)
    if (option.method.toUpperCase() === 'GET') {
        xhr.open(option.method, option.url + '?' + qs)
        xhr.send()
        // POST请求
    } else if (option.method.toUpperCase() === 'POST') {
        xhr.open(option.method, option.url)
        xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded')
        xhr.send(qs)
    }
    xhr.onreadystatechange = function () {
        if (xhr.readyState === 4 && xhr.status === 200)
            // 获取服务器响应的数据
            // console.log(xhr.responseText)
            var str = JSON.parse(xhr.responseText)
        option.success(str)
    }

}